<template>
    <div>
      <img :src="img" class="web-banner">
      <div class="breadcrumb-main">
        <div class="breadcrumb-inner">
          <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/web/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>询价采购</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
      </div>
      <div class="web-inner-main">
        <form-create 
        v-model="params.fApi" 
        :rule="params.rule" 
        :option="params.option" 
        @btn-search-click="loadList(true)"/>
       <web-list
        :key="keys"
        :tableData="tables.tableData" 
        :tableLabel="tables.tableLabel" 
        :models="tables"
        @on-search-click="loadList" />
      </div>
    </div>
  </template>
  <script>
  import {getWebBidList} from "@/api/web_api"
  import { ACCESS_TOKEN } from "@/config/common"
  import banner_img from "@/assets/home_banner.jpg"
  import { PARAMS_INQUIRY,LABEL_INQUIRY,OPTION_INLINE} from "./webModel/web_form"
  import webList from "./webModel/web_model_list"
  export default {
    name:"webInquiry",
    components:{
      webList
    },
    data() {
      return {
        img:banner_img,
        keys:0,
        params:{
          fApi:{},
          rule:PARAMS_INQUIRY,
          option:OPTION_INLINE
        },
        tables:{
          total:0,
          tableData:[],
          tableLabel: LABEL_INQUIRY
        },
        page:{
          pageNum:1,
          pageSize:10,
        },
      };
    },
    mounted() {
      // let hasToken = sessionStorage.getItem(ACCESS_TOKEN);
      // if(hasToken){
      //   this.loadList(true);
      // }else{
      //  this.tables.tableData = [];
      // }
      // this.$nextTick(()=>{
      //   this.params.fApi.setValue({"name":""});
      // })
    },
    methods: {
      async loadList(formData) {
        let params = {};
        let query = this.params.fApi.bind();
        params.name = query.name;
        if(formData !== undefined && formData.type === 'page'){
          this.page.pageNum = formData.pageNum;
          this.page.pageSize = formData.pageSize;
        }
        if(formData===true){
          this.page.pageNum = 1;
          this.keys++;
        }
        params.bidType = 1;
        params.pageNum = this.page.pageNum;
        params.pageSize = this.page.pageSize;
        const {code,data} = await getWebBidList(params);
        if(code === 200){
          this.tables.tableData = data.list;
          this.tables.total = data.total;
        }else{
          this.tables.tableData = [];
        }
      },
    }
  };
  </script>
  <style>
    
  </style>